package com.suse.service.community.util;

/**
 * <p>
 * Redis工具类
 * </p>
 *
 * @author 辜玉彬
 * @since 2022-09-02 13:33
 */
public class RedisUtil {

    private static final String ENTITY_LIKE_KEY_PRIFIX = "community:entity:like:";

    private static final String USER_LIKE_KEY_PRIFIX = "community:user:like:";

    private static final String ATTENTIONS_KEY_PRIFIX = "community:attentions:";

    private static final String FOLLOWERS_KEY_PRIFIX = "community:followers:";

    private static final String UV_KEY_PRIFIX = "community:uv:";

    private static final String DVU_KEY_PRIFIX = "community:dvu:";

    private static final String NEED_REFRESH_SCORE_POSTS_KEY = "community:need_refresh_score:posts";

    public static String getEntityLikeKey(int entityId) {
        return ENTITY_LIKE_KEY_PRIFIX + entityId;
    }

    public static String getUserLikeKey(int userId) {
        return USER_LIKE_KEY_PRIFIX + userId;
    }

    public static String getAttentionsKey(int userId) {
        return ATTENTIONS_KEY_PRIFIX + userId;
    }

    public static String getFollowersKey(int userId) {
        return FOLLOWERS_KEY_PRIFIX + userId;
    }

    // 单日UV
    public static String getUVKey(String date) {
        return UV_KEY_PRIFIX + date;
    }

    // 区间UV
    public static String getUVKey(String start,String end) {
        return UV_KEY_PRIFIX + start + "~" + end;
    }

    // 单日活跃用户
    public static String getDVUKey(String date) {
        return DVU_KEY_PRIFIX + date;
    }

    // 区间活跃用户
    public static String getDVUKey(String start,String end) {
        return DVU_KEY_PRIFIX + start + "~" + end;
    }

    // 需要刷新分数的帖子
    public static String getNeedRefreshScorePostsKey() {
        return NEED_REFRESH_SCORE_POSTS_KEY;
    }

}
